﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>选中表格行前的复选框则行变色</title>
    <script language="javascript">


    </script>
</head>
<body>
<table align="center" border="0" cellpadding="0" cellspacing="0" width="50%">
    <tr>
        <td bgcolor="#CC6655">
            <input name="checkbox" onClick="if(this.checked){
                this.parentNode.parentNode.style.background='#cc5566'
            }else{
                this.parentNode.parentNode.style.background=''}" 
                   type="checkbox"
                                     value="checkbox">
            全选
        </td>
    </tr>
    <tr>
        <td>
            <table border="0" cellpadding="0" cellspacing="0" id="tab1" width="100%">
                <tr>
                    <td><input name="checkbox" onclick="if(this.checked){this.parentNode.parentNode.style.background='#cc5566'}else{this.parentNode.parentNode.style.background=''}" type="checkbox"
                               value="checkbox">
                        第一行
                    </td>
                    <td>第二列</td>
                </tr>
                <tr>
                    <td><input name="checkbox" onclick="if(this.checked){this.parentNode.parentNode.style.background='#cc5566'}else{this.parentNode.parentNode.style.background=''}" type="checkbox"
                               value="checkbox">
                        第二行
                    </td>
                    <td>第二列</td>
                </tr>
            </table>
        </td>
    </tr>
</table>
</body>
</html>